home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / regkey22.zip / REGKEY.DOC < prev    next >
Text File  |  1992-12-21  |  17KB  |  310 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                    REGISTRATION KEY SYSTEM FOR PROGRAMMERS
  9.                                  Version 2.20
  10.  
  11.  
  12.            (C) Copyright 1992, Brian Pirie. All Rights Reserved.
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.     You are granted permission to use an unmodified version of this code
  21.     in any program, so long as your program's documentation acknowledges
  22.     the use of this code. There is no charge for the use of this
  23.     software.
  24.  
  25.  
  26.  
  27.  
  28.     This brief document describes the accompanying files which can be
  29.     used to easily implement a registration key system in any programs
  30.     which you have written. I would encourage you to read this entire
  31.     file, prior to attempting to use this system - there is some very
  32.     important information contained withing, that may not seem obvious
  33.     prior to reading this document.
  34.  
  35.     First of all, if you are currently using the REGKEY10.* library,
  36.     please note that the new versions 2.00 and later is NOT an upgrade
  37.     from version 1.00, but a re-written algorithm. This means that the
  38.     new package will produce different registration key values than the
  39.     old one. Therefore, if you are using REGKEY10 in any of your
  40.     programs, you should not try to recompile the same program using
  41.     this new package.
  42.  
  43.     As of version 2.10, the registration key systems should be
  44.     compatible with any compiler that supports the MicroSoft .OBJect
  45.     code format. While all of the example programs included with this
  46.     package are in C, the package should be compatible with any
  47.     language, including Pascal, BASIC and Assembly language, which
  48.     supports the C function calling convention. The registration key
  49.     system should be compatible with Turbo C(++), Borland C++, MicroSoft
  50.     Quick C, MicroSoft C(++), Turbo Pascal, QuickBASIC, Visual BASIC,
  51.     and many other compilers.
  52.  
  53.     Version 2.20 of this package includes only a few minor changes, such
  54.     as automatic C++ detection in the C header file, and changes to the
  55.     documentation and example programs.
  56.  
  57.     Using this registration key system, you can easily and quickly
  58.     generate and verify the validity of numerical registration keys that
  59.     correspond to a person who has purchased your program. Thus, when
  60.     someone who already has a shareware or demo version of your program
  61.     wishes to purchase the program, you need only send them a simple
  62.     registration key number, instead of sending an entire registered
  63.     version. You can simply use this package to generate a unique
  64.     registration key number which corresponds to the user's name (or any
  65.     other string you wish to use). The user will then be able to enter
  66.     this number into your software's configuration file / configuration
  67.     program. When your program begins, it will be able to read this
  68.     number from the configuration file, and again using this package,
  69.     determine whether it is a valid registration key corresponding to
  70.     the user's name. If the registration key is valid, your program can
  71.     switch into "registered mode", and if not, can run in its
  72.     unregistered "demo" mode.
  73.  
  74.     Unlike other registration key algorithms, this package can be used
  75.     over and over, by many different programs and programmers. Each
  76.     program written to use this package simply provides the registration
  77.     algorithm with its own unique numerical security code. This way, the
  78.     registration key for a user named "Brian Pirie" might be 4042871256
  79.     for one program, while the registration key for "Brian Pirie" could
  80.     be 1732396345 for another program.
  81.  
  82.     Below are detailed instructions for the use of the registration key
  83.     system in C programs. If you wish to use this package with any other
  84.     language, you should still read the rest of this manual. However,
  85.     you will probably also have to refer to other books / manuals for
  86.     instructions on calling C functions from withing whatever language
  87.     you are using.
  88.  
  89.     In order to make use of this registration key system in your
  90.     program, you must take a few simple steps when writing and compiling
  91.     your program:
  92.  
  93.     1.) First of all, you must include the "BP.H" header file in your
  94.         program. This can be accomplished by adding the line:
  95.  
  96.                #include "bp.h"
  97.  
  98.         at the beginning of your program.
  99.  
  100.     2.) Secondly, you must instruct your C compiler to link your program
  101.         with the appropriate BP?.LIB. The library you use should
  102.         correspond to the same memory model you use to compile your
  103.         program. The memory models and their corresponding library files
  104.         are listed below:
  105.  
  106.                 BPT.LIB - Tiny Memory Model
  107.                 BPS.LIB - Small Memory Model
  108.                 BPC.LIB - Compact Memory Model
  109.                 BPM.LIB - Medium Memory Model
  110.                 BPL.LIB - Large Memory Model
  111.                 BPH.LIB - Huge Memory Model
  112.  
  113.         In order to have your program linked with one of these
  114.         libraries, you can create a makefile or project file, which
  115.         lists the name of your program's source code file(s), along with
  116.         the filename of the appropriate libary. For more information on
  117.         doing this, refer to the manuals which came with your compiler.
  118.  
  119.     You will now be able to make use of the registration key function.
  120.     This function's prototype is listed below:
  121.  
  122.       unsigned long bp(char *registration_string, unsigned int security_code);
  123.  
  124.     As you can see, this function accepts two parameters. The first
  125.     parameter, registration_string, is a pointer to the string which
  126.     should be used to generate the registration key. This will usually
  127.     be the name of the person who has registered (purchased) your
  128.     program. The second parameter, security_code, should be a number
  129.     between 0 and 65,535, which should be a unique value for any given
  130.     program you have written. It is this parameter that makes a user's
  131.     registration key unique for your program, and which prevents other
  132.     people who may have this package from producing registration keys
  133.     for use with your program. Note that you may have to experiment to
  134.     find a suitable security code. Due to the nature of the registration
  135.     key algorithm, some security codes may result in registration keys
  136.     that are always 0. The bp() function will return the registration
  137.     key corresponding to the registration string and security code, as
  138.     an unsigned long integer. In your registration key GENERATION
  139.     PROGRAM, this is the value which you will display, in order to send
  140.     to the registered user. In the ACTUAL PROGRAM that the user is
  141.     registering, you will compare this value with the value supplied by
  142.     the user in your configuration file / configuration program. If and
  143.     only if these values match, your program should then operate in
  144.     "registered" mode.
  145.  
  146.     You can also make use of the included MAKEKEY program to generate
  147.     registration keys to send to registered users. Run this program by
  148.     simply typing MAKEKEY from the DOS prompt. You will then be prompted
  149.     to enter the unique security code used by your program, and the name
  150.     of the user who has registered. This program will then display the
  151.     registration key corresponding to the supplied registration string
  152.     (user's name). Again, remember that it is the security code which
  153.     prevents other people from creating registration keys for use with
  154.     your program, and as such, it is important that you keep your
  155.     program's security code confedential.
  156.  
  157.     When using this registration key system, be careful not to accept
  158.     registration strings (ie, the user's name) which are empty. The
  159.     registration system will always return the same value for an empty
  160.     string. Thus, you should check the length of the name the user has
  161.     entered, and if it is 0, automatically assume that the user is not
  162.     registered, and do not call the bp() function at all.
  163.  
  164.     The source code to the MAKEKEY program is included in the file
  165.     MAKEKEY.C. Feel free to alter this makekey program in any way you
  166.     wish. For example, you may want to create a custom version of the
  167.     MAKEKEY program for each of your programs in which you use the
  168.     registration key system. You would then be able to hard-code your
  169.     program's security code into your registration key gerneration
  170.     program, to eliminate the need of entering the security code every
  171.     time a user registers.
  172.  
  173.     As an example of the use of the registration key system, say you
  174.     have written a program, and chosen 24805 as your security code. Now,
  175.     when the user registers your program, you would use the MAKEKEY key
  176.     program to generate a registration key which corresponds to the
  177.     exact spelling and capitalization of their name, and send this
  178.     registration key to them. The user would then enter their name,
  179.     exactly how it appeared on their registration form, along with the
  180.     registration key you have sent them, into either a configuration
  181.     file or configuration program. You would then be able to read this
  182.     information from the configuration file, from within your program.
  183.     You program would then determine the registration key which would
  184.     correspond to the user's name, and compare this registration key to
  185.     the key supplied by the user. If the values match, then your program
  186.     would run in registered mode, and if the values do not match, then
  187.     your program would run in unregistered mode. Keep in mind that
  188.     registration keys used in this system are always of type unsigned
  189.     long. Below is an example of part of a program which uses the
  190.     registration key system. This program will read the registration
  191.     information from the file REGISTER.KEY, taking the first line to be
  192.     the name of the registered user, and the second line to be the
  193.     user's registration key. Remember this program uses 24805 as its
  194.     security code - you will want to change this value in any programs
  195.     you write. This is also the value you will have to supply to the
  196.     MAKEKEY program, when generating keys for use with the program
  197.     below. The source code to this program is also listed in the file
  198.     USEKEY.C.
  199.  
  200.         #include "bp.h"      // Include the registration key system header file
  201.  
  202.         #include <stdio.h>                              // Other C header files
  203.         #include <string.h>
  204.  
  205.         char is_reged=0;                           // 1 if registered, 0 if not
  206.         char registered_name[201];                   // Name of registered user
  207.  
  208.         main()                                         // Main program function
  209.            {
  210.            FILE *fp;                      // File pointer for REGISTER.KEY file
  211.            unsigned long supplied_key;                  // Key supplied by user
  212.            unsigned long correct_key;               // Correct registration key
  213.  
  214.            if((fp=fopen("REGISTER.KEY","r"))!=NULL)         // Try to open file
  215.               {                                                // If successful
  216.               fgets(registered_name,200,fp);             // read name from file
  217.               if(registered_name[strlen(registered_name)-1]=='\n')
  218.                  registered_name[strlen(registered_name)-1]='\0';
  219.  
  220.               fscanf(fp,"%lu",&supplied_key);             // read key from file
  221.  
  222.               fclose(fp);                                         // Close file
  223.  
  224.               correct_key=bp(registered_name,24805);   // Calculate correct key
  225.  
  226.               if(correct_key==supplied_key)  // Compare correct & supplied keys
  227.                  {                                     // If they are identical
  228.                  is_reged=1;        // Then switch program into registered mode
  229.                  }
  230.               }
  231.  
  232.            if(is_reged==1)                                // If registered mode
  233.               {                             // Display registration information
  234.               printf("This program is registered to: %s\n",registered_name);
  235.               }
  236.            else if(is_reged==0)                    // If not in registered mode
  237.               {                             // Display unregistered information
  238.               printf("This program is UNREGISTERED!!!\n");
  239.               }
  240.            }
  241.  
  242.     An alternative means of implementing the registration key system in
  243.     your programs is instead of sending the user a numerical value which
  244.     they enter into your program's configuration, to send them a
  245.     registration key file. This file, similar to that used in the above
  246.     program, would simply contain the user's name and registration key,
  247.     in any format you choose. Your "MAKEKEY" program would then generate
  248.     this file, and your distributed software would read this file, if
  249.     available.
  250.  
  251.     I have decided to make it my policy NOT to release the source code
  252.     for this registration key algorithm. The reason for this is simply
  253.     for the protection of yourself and anyone else wishing to use this
  254.     algorithm in their programs. If the source code to this algorithm
  255.     became widely available, it would be easier (though still next to
  256.     impossible), for someone to be able to produce false registration
  257.     keys for your program. If you would like a version of BID for a
  258.     compiler that does not support the MicroSoft .OBJect file format, I
  259.     would be more than willing to compile a version for this compiler
  260.     for you, if you can LEGALLY provide me with a copy of this compiler.
  261.     For instance, it is commonly the case that your compiler's licence
  262.     agreement permits the use of the compiler by more than one party,
  263.     provided that it is not used by both parties at the same time. If
  264.     such a licence agreement were to permit you to send me a copy of the
  265.     compiler to compile a version of the library with that compiler, and
  266.     then I erase the copy of the compiler you sent me, I would be
  267.     willing to do this.
  268.  
  269.     What I can tell you about the algorithm, is that it uses several
  270.     steps in the generation of the registration key. Each of these steps
  271.     use a completely different approach, in order to provide greater
  272.     security. Also, the security code provided by your program is
  273.     actually broken down into several bit-fields, each of which is used
  274.     to alter the output of a different level of the overall algorithm.
  275.     As a result, the most security is obtained by using a security code
  276.     which has both high and low bits throughout the 16-bit value. As a
  277.     general rule, try to choose security codes above 10000. Also note
  278.     that the registration string can not exceed 200 characters in
  279.     length.
  280.  
  281.     In no event will I, Brian Pirie, be liable to you for any damages,
  282.     including any lost profits, lost savings, or other incidental or
  283.     consequential damages arising out of the use or inability to use
  284.     this software. While every effort has been made to make this
  285.     registration key system as secure as possible, please remember that
  286.     NO such system is "hack-proof", and that I can not take any
  287.     responsibility for any difficulties with this software.
  288.  
  289.     I hope you enjoy this package and find it useful. If you are having
  290.     any difficulty with this package, I would be more than happy to
  291.     provide any assistance I can offer. If you would like to get in
  292.     touch with me for any reason at all, please feel more than free to
  293.     do so by any of the following means.
  294.  
  295.     I can be contacted at -   FidoNet : 1:243/8
  296.                              InterNet : brian@bpecomm.pinetree.org
  297.                            Data (BBS) : +1 613 526 4466
  298.                                Postal : 1416 - 2201 Riverside Dr.
  299.                                         Ottawa, Ontario
  300.                                         Canada
  301.                                         K1H 8K9
  302.  
  303.     *** PLEASE NOTE *** If you wish to send FidoNet CrashMail, please
  304.                         indicate whether I should reply to your message
  305.                         by routed netmail, or by placing my reply on
  306.                         hold for you to poll to pick up. While I would
  307.                         like to be able to reply to all your message by
  308.                         by CrashMail, financial constraints will not
  309.                         permit this.
  310.